﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HamsterSimulator
{
    public class HamsterEditorViewModel : BaseViewModel
    {
        public HamsterEditorViewModel()
        {
            Document = new ICSharpCode.AvalonEdit.Document.TextDocument("void Main()\n{\n    Vor();\n    RechtsUm();\n    Vor();\n}\n\nvoid RechtsUm()\n{\n    LinksUm();\n    LinksUm();\n    LinksUm();\n}");

            // I love readable code...
            StartSimulator = new DelegateCommand((args) =>
            {
                    HamsterEngine.SimulationWindow.Simulation.Show(RawCode);
            });
        }

        private ICSharpCode.AvalonEdit.Document.TextDocument document;
        public ICSharpCode.AvalonEdit.Document.TextDocument Document
        {
            get { return document; }
            set { document = value; OnPropertyChanged("Document"); }
        }

        public string RawCode
        {
            get { return Document.Text; }
            set
            {
                Document.Text = value;
                OnPropertyChanged("Document");
            }
        }

        public DelegateCommand StartSimulator { get; protected set; }
    }
}
